package com.qdlc.p2p.biz.util;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.qdlc.p2p.common.util.NumberUtil;
import com.qdlc.p2p.common.util.SinaTools;

/**
 * 负责处理新浪通知请求的处理类
 * <p> 
 * 		负责对新浪返回的通知请求的封装，提供验签、返回响应、获取通知参数等功能。
 * </p>
 * @author linya 2015-12-30
 */
public class NotifyRequestHandler {

	
	Map<String, String> notifyParam;	//获取的通知请求参数
	
	
	public static NotifyRequestHandler build(HttpServletRequest request){
		NotifyRequestHandler notify = new NotifyRequestHandler();
		notify.notifyParam = SinaTools.getParameterMap(request, true);
		return notify;
	}
	
	public boolean checkSign(){
		return true;
	}
	
	/**
	 * 获取参数
	 * @param key
	 * @return
	 */
	public String getParam(String key){
		return notifyParam.get(key);
	}
	
	public int getIntParam(String key){
		return NumberUtil.getInt(notifyParam.get(key));
	}
	
	public double getDoubleParam(String key){
		return NumberUtil.getDouble2(notifyParam.get(key));
	}
	
}
